package com.hundun.hddeal.service.lmpl;

import com.hundun.hddeal.dao.PublishMapper;
import com.hundun.hddeal.entity.Publish;
import com.hundun.hddeal.response.Result;
import com.hundun.hddeal.response.ResultUtil;
import com.hundun.hddeal.service.PublishService;
import org.apache.ibatis.session.SqlSessionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 评价业务层
 * @author 谢
 */
@Service
public class PublishServiceImpl implements PublishService {

    @Autowired
    PublishMapper publishMapper;

    @Override
    public Result deleteByPrimaryKey(Integer id) {
        return null;
    }

    @Override
    public Result insertSelective(Publish record) {
        try{
            publishMapper.insertSelective(record);
            return ResultUtil.success();
        }catch (SqlSessionException e){
            e.printStackTrace();
            return ResultUtil.error();
        }
    }

    @Override
    public Result<Publish> selectByPrimaryKey(String orderId) {
        try{
            List<Publish> publishs=publishMapper.selectByPrimaryKey(orderId,null);
            return ResultUtil.success(publishs.get(0));//返回订单评价第一条则是全部的评价
        }catch (SqlSessionException e){
            e.printStackTrace();
            return ResultUtil.error();
        }
    }

    @Override
    public Result updateByPrimaryKeySelective(Publish record) {
        return null;
    }
}
